package com.codechuan.didi_web.controller;

import com.codechuan.didi_web.service.SysUserConfigService;
import com.codechuan.didi_web.utils.ResultUtils;
import com.codechuan.didi_web.vo.ResultVO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/config")
public class ConfigController {
    @Resource
    private SysUserConfigService sysUserConfigService;

    /**
     * @Deprecated 获取用户配置文件
     * @param account token
     * @return 返回用户配置文件
     */
    @GetMapping(value = "/getUserConfig")
    public ResultVO<Object> getUserConfig(@RequestHeader("token") String account){
        try {
            return ResultUtils.success(sysUserConfigService.getUserConfig(account));
        }catch (Exception e){
            return ResultUtils.error(500,"网络异常请重新刷新页面","");
        }
    }

    /**
     * @Deprecated 获取主号token和按钮状态  经纬度等信息
     * @param account token
     * @return 返回查询到的数据
     */
    @GetMapping(value = "/getMainTokenAndButtonStatus")
    public ResultVO<Object> getMainTokenAndButtonStatus(@RequestHeader("token") String account){
        try {
            return ResultUtils.success(sysUserConfigService.getMainTokenAndButtonStatus(account));
        }catch (Exception e){
            return ResultUtils.error(500,"网络异常请重新刷新页面","");
        }
    }

    /**
     * @Deprecated 获取用户的token列表
     * @param account token
     * @return 返回查询到的数据
     */
    @GetMapping(value = "/getUserTokenList")
    public ResultVO<Object> getUserTokenList(@RequestHeader("token") String account){
        try {
            return ResultUtils.success(sysUserConfigService.getUserTokenList(account));
        }catch (Exception e){
            return ResultUtils.error(500,"网络异常请重新刷新页面","");
        }
    }

    /**
     * @Deprecated 获取用户的token列表
     * @param account token
     */
    @GetMapping(value = "/updateAccountTokenSxNumber")
    public ResultVO<Object> updateAccountTokenSxNumber(@RequestHeader("token") String account,String phone,String sxNumber){
        try {
            return ResultUtils.success(sysUserConfigService.updateAccountTokenSxNumber(account,phone,sxNumber),"修改成功");
        }catch (Exception e){
            return ResultUtils.error(500,"网络异常请重新刷新页面","");
        }
    }

}
